﻿package com.wongoing.sys.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wongoing.base.BaseServiceImpl;
import com.wongoing.base.PageResult;
import com.wongoing.sys.dao.SysPostDao;
import com.wongoing.sys.model.SysPost;
import com.wongoing.sys.service.SysPostService;

@Service("sysPostService")
public class SysPostServiceImpl extends BaseServiceImpl<SysPost> implements SysPostService {
	private SysPostDao dao;

	@Autowired
	public void setDao(SysPostDao dao) {
		super.setDao(dao);
		this.dao = dao;
	}

	/**
	 * 功能说明：获取总数分页数据
	 * 修改说明：
	 * @author zhenglibing
	 * @date 2017年10月14日 下午9:25:08
	 * @param params 分页查询对象，包含查询条件
	 * @return 返回分页查询对象，包含页面数据
	 */
	public PageResult<SysPost> getPostListPageResult(PageResult<SysPost> pageResult) {
		pageResult.getParam().put("offset", pageResult.getPageSize() * (pageResult.getPageCurrent() - 1));
		pageResult.getParam().put("limit", pageResult.getPageSize());
		if (!"".equals(pageResult.getOrderField())) { pageResult.getParam().put("orderColumn", pageResult.getOrderField()); }
		pageResult.getParam().put("orderTurn", pageResult.getOrderDirection());
		List<SysPost> data = this.dao.getPostListByParam(pageResult.getParam());
		pageResult.setList(data);
		int totalSize = this.dao.countOfPostListByParam(pageResult.getParam());
		pageResult.setTotal(totalSize);
		return pageResult;
	}

}
